//    Copyright (C) 2013  <lugocreation@gmail.com>
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.jpgolay.me.agency;

import net.sf.jasperreports.engine.*;

// Referenced classes of package org.jpgolay.me.agency:
//            Agency
public class AgencyPrintDataSource
        implements JRDataSource {

    public AgencyPrintDataSource(Agency agency) {
        this.agency = agency;
        count = 130;
    }

    public boolean next()
            throws JRException {
        return count > 0;
    }

    public Object getFieldValue(JRField field)
            throws JRException {
        String fieldname = field.getName();
        String value = null;
        if ("id".equals(fieldname)) {
            value = agency.getId().toString();
        } else if ("company".equals(fieldname)) {
            value = agency.getRaisonSociale();
        } else if ("status".equals(fieldname)) {
            value = agency.getCivilite();
        } else if ("addrLn1".equals(fieldname)) {
            value = agency.getAdresseUn();
        } else if ("addrLn2".equals(fieldname)) {
            value = agency.getAdresseDeux();
        } else if ("zip".equals(fieldname)) {
            value = agency.getCp();
        } else if ("city".equals(fieldname)) {
            value = agency.getVille();
        } else if ("tel1".equals(fieldname)) {
            if (agency.getTelephoneUn() != null) {
                value = "T\351l : " + agency.getTelephoneUn();
            }
        } else if ("fax1".equals(fieldname)) {
            if (agency.getFaxUn() != null) {
                value = "Fax : " + agency.getFaxUn();
            }
        } else if ("email".equals(fieldname)) {
            if (agency.getEmail() != null) {
                value = "Email : " + agency.getEmail();
            }
        } else if ("web".equals(fieldname)) {
            if (agency.getSiteWeb() != null) {
                value = "Site web : " + agency.getSiteWeb();
            }
        } else if ("naf".equals(fieldname)) {
            if (agency.getNaf() != null) {
                value = "Naf : " + agency.getNaf();
            }
        } else if ("siret".equals(fieldname) && agency.getSiret() != null) {
            value = "Siret : " + agency.getSiret();
        }
        count--;
        return value;
    }
    private Agency agency;
    private int count;
}
